import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'

// 加载插件
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import tailwindcss from '@tailwindcss/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
    tailwindcss(),
    Icons({ compiler: 'vue3', autoInstall: true }),
    Components({ dts: true, resolvers: [IconsResolver()] }),
    AutoImport({
      dts: true,
      imports: ['vue', 'vue-router', 'pinia'],
      dirs: ['src/composables', 'src/stores', 'src/ui'],
      vueTemplate: true,
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
})
